package simulacao;

import java.util.logging.Level;
import java.util.logging.Logger;
import java.io.*;
import lejos.pc.comm.NXTConnector;

public class Cliente {

    private DataOutputStream out;
    private DataInputStream in;

    public Cliente() {
        //char c=' ';
        NXTConnector conn = new NXTConnector();
        conn.setDebug(true);
        if (conn.connectTo("btspp://00:16:53:08:18:25")) {
            out = conn.getDataOut();
            in = conn.getDataIn();
        } else {
            System.out.println("Erro de conexão");
        }
    }

    public void send(char c) {
        try {
            out.writeChar(c); //comando enviado
            out.flush();
            System.out.println("N: " + (in.readBoolean() ? "T" : "F"));
            System.out.println("S: " + (in.readBoolean() ? "T" : "F"));
            System.out.println("L: " + (in.readBoolean() ? "T" : "F"));
            System.out.println("O: " + (in.readBoolean() ? "T" : "F"));
        } catch (IOException ex) {
            Logger.getLogger(Cliente.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
}
